package cn.iocoder.yudao.module.jky.dal.mysql.order;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.jky.controller.admin.order.vo.OrderExportReqVO;
import cn.iocoder.yudao.module.jky.controller.admin.order.vo.OrderPageReqVO;
import cn.iocoder.yudao.module.jky.dal.dataobject.order.OrderDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 订单 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface OrderMapper extends BaseMapperX<OrderDO> {

    default PageResult<OrderDO> selectPage(OrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderDO>()
                .eqIfPresent(OrderDO::getUserId, reqVO.getUserId())
                .eqIfPresent(OrderDO::getOrderNum, reqVO.getOrderNum())
                .eqIfPresent(OrderDO::getTitle, reqVO.getTitle())
                .eqIfPresent(OrderDO::getAllprice, reqVO.getAllprice())
                .eqIfPresent(OrderDO::getGivePoint, reqVO.getGivePoint())
                .eqIfPresent(OrderDO::getProffer, reqVO.getProffer())
                .eqIfPresent(OrderDO::getProfferStatus, reqVO.getProfferStatus())
                .eqIfPresent(OrderDO::getDeductionPoint, reqVO.getDeductionPoint())
                .eqIfPresent(OrderDO::getProvince, reqVO.getProvince())
                .eqIfPresent(OrderDO::getCity, reqVO.getCity())
                .eqIfPresent(OrderDO::getCounty, reqVO.getCounty())
                .eqIfPresent(OrderDO::getAddress, reqVO.getAddress())
                .eqIfPresent(OrderDO::getCompany, reqVO.getCompany())
                .eqIfPresent(OrderDO::getConsignee, reqVO.getConsignee())
                .eqIfPresent(OrderDO::getContactNumber, reqVO.getContactNumber())
                .eqIfPresent(OrderDO::getPostcode, reqVO.getPostcode())
                .eqIfPresent(OrderDO::getLogistics, reqVO.getLogistics())
                .eqIfPresent(OrderDO::getExpressNumber, reqVO.getExpressNumber())
                .eqIfPresent(OrderDO::getRemark, reqVO.getRemark())
                .eqIfPresent(OrderDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(OrderDO::getPayTime, reqVO.getPayTime())
                .betweenIfPresent(OrderDO::getDeliverTime, reqVO.getDeliverTime())
                .betweenIfPresent(OrderDO::getFinishTime, reqVO.getFinishTime())
                .betweenIfPresent(OrderDO::getCommentTime, reqVO.getCommentTime())
                .betweenIfPresent(OrderDO::getRefundTime, reqVO.getRefundTime())
                .betweenIfPresent(OrderDO::getRefundSuccessTime, reqVO.getRefundSuccessTime())
                .betweenIfPresent(OrderDO::getRefundFailTime, reqVO.getRefundFailTime())
                .eqIfPresent(OrderDO::getPayMethod, reqVO.getPayMethod())
                .eqIfPresent(OrderDO::getPoint, reqVO.getPoint())
                .eqIfPresent(OrderDO::getConsumerCode, reqVO.getConsumerCode())
                .eqIfPresent(OrderDO::getDrawbackReason, reqVO.getDrawbackReason())
                .eqIfPresent(OrderDO::getDrawbackImg, reqVO.getDrawbackImg())
                .eqIfPresent(OrderDO::getDrawbackRefuseReason, reqVO.getDrawbackRefuseReason())
                .eqIfPresent(OrderDO::getRefundExpressNumber, reqVO.getRefundExpressNumber())
                .eqIfPresent(OrderDO::getIsDelay, reqVO.getIsDelay())
                .betweenIfPresent(OrderDO::getCancelTime, reqVO.getCancelTime())
                .eqIfPresent(OrderDO::getType, reqVO.getType())
                .eqIfPresent(OrderDO::getSupplierId, reqVO.getSupplierId())
                .inIfPresent(OrderDO::getStatus,reqVO.getCheckingStatus())
                .orderByDesc(OrderDO::getId));
    }

    default List<OrderDO> selectList(OrderExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OrderDO>()
                .eqIfPresent(OrderDO::getUserId, reqVO.getUserId())
                .eqIfPresent(OrderDO::getOrderNum, reqVO.getOrderNum())
                .eqIfPresent(OrderDO::getTitle, reqVO.getTitle())
                .eqIfPresent(OrderDO::getAllprice, reqVO.getAllprice())
                .eqIfPresent(OrderDO::getGivePoint, reqVO.getGivePoint())
                .eqIfPresent(OrderDO::getProffer, reqVO.getProffer())
                .eqIfPresent(OrderDO::getProfferStatus, reqVO.getProfferStatus())
                .eqIfPresent(OrderDO::getDeductionPoint, reqVO.getDeductionPoint())
                .eqIfPresent(OrderDO::getProvince, reqVO.getProvince())
                .eqIfPresent(OrderDO::getCity, reqVO.getCity())
                .eqIfPresent(OrderDO::getCounty, reqVO.getCounty())
                .eqIfPresent(OrderDO::getAddress, reqVO.getAddress())
                .eqIfPresent(OrderDO::getCompany, reqVO.getCompany())
                .eqIfPresent(OrderDO::getConsignee, reqVO.getConsignee())
                .eqIfPresent(OrderDO::getContactNumber, reqVO.getContactNumber())
                .eqIfPresent(OrderDO::getPostcode, reqVO.getPostcode())
                .eqIfPresent(OrderDO::getLogistics, reqVO.getLogistics())
                .eqIfPresent(OrderDO::getExpressNumber, reqVO.getExpressNumber())
                .eqIfPresent(OrderDO::getRemark, reqVO.getRemark())
                .eqIfPresent(OrderDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(OrderDO::getPayTime, reqVO.getPayTime())
                .betweenIfPresent(OrderDO::getDeliverTime, reqVO.getDeliverTime())
                .betweenIfPresent(OrderDO::getFinishTime, reqVO.getFinishTime())
                .betweenIfPresent(OrderDO::getCommentTime, reqVO.getCommentTime())
                .betweenIfPresent(OrderDO::getRefundTime, reqVO.getRefundTime())
                .betweenIfPresent(OrderDO::getRefundSuccessTime, reqVO.getRefundSuccessTime())
                .betweenIfPresent(OrderDO::getRefundFailTime, reqVO.getRefundFailTime())
                .eqIfPresent(OrderDO::getPayMethod, reqVO.getPayMethod())
                .eqIfPresent(OrderDO::getPoint, reqVO.getPoint())
                .eqIfPresent(OrderDO::getConsumerCode, reqVO.getConsumerCode())
                .eqIfPresent(OrderDO::getDrawbackReason, reqVO.getDrawbackReason())
                .eqIfPresent(OrderDO::getDrawbackImg, reqVO.getDrawbackImg())
                .eqIfPresent(OrderDO::getDrawbackRefuseReason, reqVO.getDrawbackRefuseReason())
                .eqIfPresent(OrderDO::getRefundExpressNumber, reqVO.getRefundExpressNumber())
                .eqIfPresent(OrderDO::getIsDelay, reqVO.getIsDelay())
                .betweenIfPresent(OrderDO::getCancelTime, reqVO.getCancelTime())
                .eqIfPresent(OrderDO::getType, reqVO.getType())
                .eqIfPresent(OrderDO::getSupplierId, reqVO.getSupplierId())
                .orderByDesc(OrderDO::getId));
    }

}
